layui.define(['table', 'form','laypage','laydate','layer'], function(exports){
    var $ = layui.$
        ,table = layui.table
        ,form = layui.form
        , laydate=layui.laydate
        , laypage = layui.laypage
        , layer = layui.layer;

    //路径
    var curWwwPath=window.document.location.href;
    var pathName=window.document.location.pathname;
    var pos=curWwwPath.indexOf(pathName);
    var localhostPaht=curWwwPath.substring(0,pos);
    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);

    var limitcount = 10;
    table.render({
        elem: '#inventoryList'
        , url: localhostPaht + projectName + "/rest/inventory/inventoryList"
        ,title:"盘点校准表",
        height: 'full-193'
        , page: false
        , limit: limitcount
        , toolbar: '#'
        , text: {
            none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
        },
        defaultToolbar: ['filter', 'print']
        , cols: [[
            // {type: 'checkbox'}
            {field: 'number', title: 'ID', width: 70, sort: true,fixed:'left'}
            , {field: 'ecpcode', title: 'EPC标签',sort: true}
            , {field: 'name', title: '物资名称',sort: true}
            , {field: 'responsible', title: '负责人员',sort: true}
            , {field: 'state', title: '盘点状态',templet: '#states',sort: true}
            , {field: 'createby', title: '操作人员',sort: true}
            , {field: 'lastmodifyby', title: '操作时间',sort: true}

        ]],
        done: function (res, curr, count) {
            if (res.errorMsg == null) {

            } else {
                layer.msg(res.errorMsg);
            }
            var curnum = $("#curnum").val();
            $('.layui-table-fixed-r').removeClass('layui-hide');//列固定右侧
            laypage.render({
                elem: 'laypage'
                ,first: '首页'
                ,last: '尾页'
                ,groups:5
                , count: count
                , curr: curnum
                , limit: limitcount
                , layout: ['prev', 'page', 'next', 'skip', 'count','limit']
                , limits:[10,15,20]
                , jump: function (obj, first) {
                    if (!first) {
                        curnum = obj.curr;
                        $("#curnum").val(curnum)
                        limitcount = obj.limit;
                        table.reload('inventoryList', { //表格的id
                            where: {
                                page: curnum,
                                limit:limitcount
                            }
                        })
                    }
                }
            })
        }
    });
    exports('inventory', {})
});